/*******************************************************************************
*
* (c) Copyright 2014 Freescale Semiconductor
*
****************************************************************************//*!
*
* @file     _Template.c
*
* @author   Salvador Zendejas
*
* @version  0.0.1
*
* @date     Aug 22, 2014
*
* @brief    System Integration Module configuration for Kinetis K.
*
*******************************************************************************/

/*******************************************************************************
* Includes
*******************************************************************************/
#include "_Template.h" /* Include peripheral declarations */
#if 0
/*******************************************************************************
* Global variables
*******************************************************************************/


/*******************************************************************************
* Local variables
*******************************************************************************/
static volatile     uint8_t appSwitchState = 0;
static int16_t  ADCResults;

/* ADC conversion sequence channel list */


/*******************************************************************************
* Constants
*******************************************************************************/
/* Array with pointers to the state machine functions */
/*static const tPointerFcn AppStateMachine[] = \
{
    AppInit,
    AppCalib,
    AppAlignment,
    AppStart,
    AppRun,
    AppStop,
    AppFault
};
*/

/* FTM2 channel output mask control */
static const uint8_t ui8FTM2OutmaskVal[2][8] =
{
    /* Clockwise rotation direction */
    {
        0x34,   /* sector 0 */
        0x1C,   /* sector 1 */
        0x13,   /* sector 2 */
        0x31,   /* sector 3 */
        0x0D,   /* sector 4 */
        0x07,   /* sector 5 */
        0x05,   /* alignment vector */
        0x3F    /* PWM off */
    },
    /* Counterclockwise rotation direction */
    {
        0x31,   /* sector 3 */
        0x13,   /* sector 2 */
        0x1C,   /* sector 1 */
        0x34,   /* sector 0 */
        0x07,   /* sector 5 */
        0x0D,   /* sector 4 */
        0x05,   /* alignment vector */
        0x3F    /* PWM off */
    }
};

/* FreeMASTER constants */



/*******************************************************************************
* Global functions
*******************************************************************************/
/*******************************************************************************
*
* Function: void NMI_ISR(void)
*
* Description:  Non-maskable interrupt service routine
*
*******************************************************************************/
void NMI_ISR(void)
{
    /* Disable non-maskable interrupt */
    //SIM_SOPT0 &= ~SIM_SOPT0_NMIE_MASK;
}

/*******************************************************************************
*
* Function: void Can_RxNotification(
*           (
*               Can_ModuleIDType    Can_ModuleID,
*               Can_IDType          Can_ID,
*               Can_DataLengthType  Can_DataLength,
*               uint8_t             *Can_Data
*           )
*
* Description:  CAN receive notification function
*
*******************************************************************************/


/*******************************************************************************
*
* Function: void ICS_Trim(void)
*
* Description:  The function trims the internal RC oscillator clock frequency
*               to 37.5kHz.
*
*               The time difference between two RTC overflows (2 RTC ticks) is
*               measured using FTM1 channel 1 input capture to determine actual
*               ICSIRCLK frequency. The FTM1 counter counts the FLL output
*               clock while the RTC counts the ICSIRCLK clock. Based
*               on the difference measured, the function adjusts
*               the ICS_C3[ICSTRIM] value until the desired ICSIRCLK frequency
*               is reached.
*
*               desired_time_diff = 2 * (40MHz / 37.5kHz) = 2133.33;
*
*******************************************************************************/


/*******************************************************************************
*
* Function: void main(void)
*
* Description: main function
*
*******************************************************************************/
#endif
